namespace Xsxiaosa.Net
{
    using System;
    using System.IO;
//jyj add
	using System.Net.Sockets;

    internal class FtpDataDownload : FtpData
    {
        // Methods
        public FtpDataDownload(Ftp ftp, Stream stream) : base(ftp, stream, FtpTransferState.Downloading)
        {
        }

        protected override int DoTransfer()
        {
            if (this._socket.Available == 0)
            {
                if (!this._socket.Socket.Poll(100, SelectMode.SelectRead))
                {
                    return 0;
                }
                if (this._socket.Available == 0)
                {
                    return -1;
                }
            }
            int num1 = this._socket.Receive(this._array);
            if (num1 == 0)
            {
                return 0;
            }
            if (this._ftpStream == null)
            {
                this._stream.Write(this._array, 0, num1);
                return num1;
            }
            this._ftpStream.WriteInternal(this._array, 0, num1);
            return num1;
        }

    }}

